<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>13-小蜜蜂飞啊飞案例</title>
  <script>
    window.onload=function (){
        // 获取鼠标坐标
        document.onmousemove=function (){
            let clientX = event.clientX;
            let clientY = event.clientY;
            // 获取图片对象
            let imgEle = document.getElementsByTagName("img")[0];
            // 设置 body 定位
            document.body.style.position="absolute";
            imgEle.style.position="absolute";
            imgEle.style.left=(clientX-imgEle.clientWidth/2)+"px";
            imgEle.style.top=(clientY-imgEle.clientHeight/2)+"px";
        }
    }
  </script>
</head>
<body>
<img src="../images/2.gif" alt="">
</body>
</html>